{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}

<div class="p-3">
	<form class="layui-form gg-form-bar border-t border-x">
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" name="user_name" placeholder="请输入补酒员关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" name="imei" placeholder="请输入设备IMEI" class="layui-input" autocomplete="off" />
		</div>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
	</form>
	<table class="layui-hide" id="device_back" lay-filter="device_back"></table>
</div>

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
<!--		<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加补酒反馈">+ 添加补酒反馈</span>-->
	</div>
</script>

<script type="text/html" id="barDemo">
<div class="layui-btn-group">
	<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</div>
</script>
<script type="text/html" id="image">
	<img src="{{d.image}}" width="30" height="30" lay-event="image"/>
</script>
<script type="text/html" id="imagesArr">
	{{# if(d.images != ''){ }}
	{{# layui.each(d.images, function(index, item){ }}
	<img src="{{item}}" width="30" height="30"  lay-event="image"/>
	{{# }); }}
	{{# }else{}}
	暂无图片
	{{#}}}
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var table = layui.table,tool = layui.tool, form = layui.form;
		layui.pageTable = table.render({
			elem: '#device_back',
			title: '补酒反馈列表',
			toolbar: '#toolbarDemo',
			url: '/admin/device_back/datalist',
			page: true,
			limit: 20,
			lineStyle:'height:auto',
			cellMinWidth: 60,
			cols: [
				[
				{
					// fixed: 'left',
					field: 'id',
					title: '编号',
					align: 'center',
					width: 80
				},{
                        field: 'user_name',
                        title: '补酒员',
                        align: 'center',
                    },{
                        field: 'imei',
                        title: '设备IMEI',
                        align: 'center',
                    },{
                        field: 'num_one',
                        title: '应补酒数量(ML)',
                        align: 'center',
                    },{
                        field: 'num_two',
                        title: '实际补酒数量(ML)',
                        align: 'center',
                    },{
                        field: 'content',
                        title: '描述情况',
                        align: 'center',
                    },{
                        field: 'create_time',
                        title: '提交时间',
                        align: 'center',
                    },
				{
					field: 'right',
					title: '操作',
					toolbar: '#barDemo',
					width: 136,
					align: 'center'
				}				
				]
			]
		});
		
		//监听表头工具栏事件
		table.on('toolbar(device_back)', function(obj){
			if (obj.event === 'add') {
				tool.side("/admin/device_back/add");
				return false;
			}
		});

		//监听表格行工具事件
		table.on('tool(device_back)', function(obj) {
			var data = obj.data;
			if (obj.event === 'read') {
				tool.side('/admin/device_back/read?id='+obj.data.id);
			}
			else if (obj.event === 'edit') {
				tool.side('/admin/device_back/edit?id='+obj.data.id);
			}
			else if (obj.event === 'del') {
				layer.confirm('确定要删除该记录吗?', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("/admin/device_back/del", { id: data.id }, callback);
					layer.close(index);
				});
			}
			if(obj.event === 'image')
			{
				var src = $(this).attr('src');
				// 在此处输入 layer 的任意代码
				layer.open({
					type: 1, // page 层类型
					area: ['500px', '500px'],
					title: '',
					shade: 0.6, // 遮罩透明度
					shadeClose: true, // 点击遮罩区域，关闭弹层
					maxmin: true, // 允许全屏最小化
					anim: 0, // 0-6 的动画形式，-1 不开启
					content: "<img src="+src+" style='width: 100%;'>"
				});
			}
			return false;
		});

		//监听搜索提交
		form.on('submit(searchform)', function(data) {
			layui.pageTable.reload({
				where: {
					user_name: data.field.user_name,
					imei: data.field.imei,
				},
				page: {
					curr: 1
				}
			});
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->